home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / jed10.zip / BYTE2STR.SRC < prev    next >
Text File  |  1993-02-26  |  1KB  |  35 lines

  1. ;---------------------------------------------------------------
  2. ;   Byte2Str  --  Converts a byte passed in AL to a string at
  3. ;                 DS:SI
  4. ;   Last update 3/8/89
  5. ;
  6. ;   1 entry point:
  7. ;
  8. ;   Byte2Str:
  9. ;      Caller must pass:
  10. ;      AL : Byte to be converted
  11. ;      DS : Segment of destination string
  12. ;      SI : Offset of destination string
  13. ;
  14. ;      This routine converts 8-bit values to 2-digit hexadecimal
  15. ;      string representations at DS:SI.  The "H" specifier is
  16. ;      *not* included.  Four separate output examples:  
  17. ;      02   B7   FF   6C
  18. ;---------------------------------------------------------------
  19.  
  20. Byte2Str   PROC
  21.            mov DI,AX                ; Duplicate byte in DI
  22.            and DI,000FH             ; Mask out high 12 bits of DI
  23.            mov BX,OFFSET Digits     ; Load offset of Digits into DI
  24.            mov AH,BYTE PTR [BX+DI]  ; Load digit from table into AH
  25.            mov [SI+1],AH            ;   and store digit into string
  26.            xor AH,AH                ; Zero out AH
  27.            mov DI,AX                ; And move byte into DI
  28.            shr DI,1                 ; Shift high nybble of byte to
  29.            shr DI,1                 ;   low nybble
  30.            shr DI,1
  31.            shr DI,1
  32.            mov AH,BYTE PTR [BX+DI]  ; Load digit from table into AH
  33.            mov [SI],AH              ;   and store digit into string
  34.            ret                      ; We're done--go home!
  35. Byte2Str   ENDP